package com.banciyuan.bcywebview.biz.setting.bansetting;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.activity.BaseActivity;
import com.banciyuan.bcywebview.base.helper.ActionbarHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by squall on 2016/3/7.
 */
public class BlockListActivity extends BaseActivity {

    private List<Fragment> mList = new ArrayList<>();
    private ViewPager mPager;
    private ActionbarHelper mActionbarHelper;
    private View mActionBarView;
    private TabLayout mTabLayout;
    private String[] tabs;

    private BlockUserFragment userFragment;
    private BlockCircleFragment circleFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.zanlist_detail_viewpager_layout);
        getFragment();
        initActionbar();
        initUi();
    }

    private void getFragment() {
        userFragment = new BlockUserFragment();
        circleFragment = new BlockCircleFragment();
        mList.add(userFragment);
        mList.add(circleFragment);
    }

    @Override
    protected void initActionbar() {
        mActionBarView = findViewById(R.id.base_action_bar);
        mActionbarHelper = new ActionbarHelper(this, mActionBarView);
        mActionbarHelper.setTitle(getString(R.string.ban_setting));
    }

    @Override
    protected void initUi() {
        tabs = new String[]{getString(R.string.user_block_list), getString(R.string.ban_circles)};
        mTabLayout = (TabLayout) findViewById(R.id.tablayout);

        mPager = (ViewPager) findViewById(R.id.pager);
        mPager.setOffscreenPageLimit(2);
        mPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mList.get(position);
            }

            @Override
            public int getCount() {
                return mList.size();
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return tabs[position];
            }
        });
        mTabLayout.setupWithViewPager(mPager);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {

    }
}
